<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DOM</title>
</head>
<body>
    <div class="d1">
        <p id="p1">段落文本1</p>
        <p>段落文本2</p>
        <p>段落文本3</p>
    </div>
    <form action="#">
        
    </form>
    <input id="addBtn" type="button" value="添加元素">
    <div>
        <label for="username">用户名：</label>
        <input type="text" id="username">
    </div>
    <script>
        let p1 = document.getElementById("p1");
        let d1 = document.querySelector(".d1");
        let ps = document.querySelectorAll(".d1>p");
        console.log(p1);
        console.log(d1);
        console.log(ps);

        let fm = document.forms[0];
        console.log(fm);

        console.log(p1.innerHTML);
        p1.innerHTML = "被修改的文本";

   
        document.getElementById("addBtn").onclick = function(){
            d1.innerHTML = "<p>添加的新元素</p>" + d1.innerHTML;
        }

        document.getElementById("username").onblur = function(){
            console.log(this.value);
        };
    </script>
</body>
</html>